package com.prs.crm.action.sys;

import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.courser.struts.BaseAction;
import org.courser.ui.PaginationSupport;
import org.hibernate.criterion.DetachedCriteria;

import com.prs.crm.domain.sys.InteriorIpSet;
import com.prs.crm.service.sys.InteriorIpSetService;

public class InteriorIpSetAction extends BaseAction{

	private static final long serialVersionUID = 1L;
	private PaginationSupport pagination;
	private Integer[] ids;
	private InteriorIpSet interiorIpSet;
	private InteriorIpSetService interiorIpSetService;
	public PaginationSupport getPagination() {
		return pagination;
	}
	public void setPagination(PaginationSupport pagination) {
		this.pagination = pagination;
	}
	public Integer[] getIds() {
		return ids;
	}
	public void setIds(Integer[] ids) {
		this.ids = ids;
	}
	public InteriorIpSet getInteriorIpSet() {
		return interiorIpSet;
	}
	public void setInteriorIpSet(InteriorIpSet interiorIpSet) {
		this.interiorIpSet = interiorIpSet;
	}
	public InteriorIpSetService getInteriorIpSetService() {
		return interiorIpSetService;
	}
	public void setInteriorIpSetService(InteriorIpSetService interiorIpSetService) {
		this.interiorIpSetService = interiorIpSetService;
	}
	@Action("listInteriorIpSet")
	public String listInteriorIpSet(){
		DetachedCriteria criteria=this.getPaginationHelper().createQuery(InteriorIpSet.class);
		pagination =this.getPaginationHelper().prepare(pagination);
		this.setPagination(this.getInteriorIpSetService().listByPage(criteria, pagination));
		return SUCCESS;
	}
	
	@Action("editInteriorIpSet")
	public String editInteriorIpSet(){
		if (ids!=null) {
			this.interiorIpSet =this.getInteriorIpSetService().get(ids[0]);
		}
		return SUCCESS;
	}
	@Action(value = "saveInteriorIpSet", results = {
			@Result(name = "success", type = "redirect", location = "listInteriorIpSet"),
			@Result(name = "error", type = "chain", location = "editInteriorIpSet")})
	public String saveInteriorIpSet(){
		this.getInteriorIpSetService().save(interiorIpSet);
		return SUCCESS;
	}
	@Action(value = "removeInteriorIpSet", results = {
			@Result(name = "success", type = "redirect", location = "listInteriorIpSet"),
			@Result(name = "error", type = "chain", location = "listInteriorIpSet")})
	public String removeInteriorIpSet(){
		if (ids!=null) {
			this.interiorIpSet=this.getInteriorIpSetService().get(ids[0]);
		}
		this.getInteriorIpSetService().batchRemove(ids);
		return SUCCESS;
	}
}
